#include "ads1115.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
extern "C" {
    #include <unistd.h>
    #include <fcntl.h>
    #include <sys/types.h>
    #include <sys/ioctl.h>
    #include <linux/types.h>
    #include <linux/i2c.h>
    #include <linux/i2c-dev.h>
}

using namespace std;

ads1115::ads1115(QObject *parent, char *filename, unsigned char dev_addr) : i2c_dev(parent,filename,dev_addr)
{

}

/**
  @description:读取指定通道的数据
  @param - pointr_reg:指针寄存器
  @param - buf:读取数据缓冲区
  @param - len:读取数据长度
  @return:操作结果
*/
int ads1115::read_data(unsigned char pointer_reg,unsigned char *buf, unsigned char len)
{
    return this->i2c_read(pointer_reg,buf,len);
}

/**
  @description:向指针寄存器指定的寄存器写入数据
  @param - pointr_reg:指针寄存器
  @param - buf:写入数据缓冲区
  @param - len:写入数据长度
  @return:操作结果
*/
int ads1115::write_data(unsigned char pointer_reg, unsigned char *buf, unsigned char len)
{
    return this->i2c_write(pointer_reg,buf,len);
}
